package com.neuedu.dao.impl;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.neuedu.dao.ClientDao;
import com.neuedu.dao.ProviderDao;
import com.neuedu.model.Provider;

//把dao接口实现类，交给spring进行管理
@Repository
public class ProviderDaoImpl implements ProviderDao {

	
	
	//代码层级的整合spring+mybatis
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;	
	public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
		this.sqlSessionTemplate = sqlSessionTemplate;
	}

	@Override
	public int countProvider() {
		return sqlSessionTemplate.getMapper(ProviderDao.class).countProvider();
	}

	@Override
	public List<Provider> findAll(Map<String, Object> map) {
		return sqlSessionTemplate.getMapper(ProviderDao.class).findAll(map);
	}

	@Override
	public int addProvider(Provider p) {
		return sqlSessionTemplate.getMapper(ProviderDao.class).addProvider(p);
	}

	@Override
	public int updateProvider(Provider p) {
		return sqlSessionTemplate.getMapper(ProviderDao.class).updateProvider(p);
	}

	@Override
	public int deleteProvider(int id) {
		return sqlSessionTemplate.getMapper(ProviderDao.class).deleteProvider(id);
	}

}
